package com.xx.service.impl;

import com.xx.mapper.BookMapper;
import com.xx.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.awt.print.Book;
import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    BookMapper bookMapper;

    @Override
    @Transactional
    public List<Book> selectAll(String book_name, String author) {
        return bookMapper.selectAll("","");
    }

    @Override
    @Transactional
    public List<Book> selectByName(String book_name) {
        return bookMapper.selectByName("来");
    }
    
    @Override
    @Transactional
    public void addBook(String bookName, String author, double price){
        System.out.println("添加保存书籍");
        Book book = new Book();
        book.setBook_name(bookName);
        book.setAuthor(author);
        book.setPrice((int) price);
        book.setCategory_id(13);
        bookMapper.addBook(book);
        int i = 1/0;
    }

    //修改图书信息
    @Override
    @Transactional
    public int updateBook(String book_name, int id) {
        return bookMapper.updateBook("剑来",5);
    }
}
